<template>
<el-card shadow="never" class="aui-card--fill">
    <div class="mod-map__ismap">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
            <el-form-item>
                <el-input v-model="dataForm.name" placeholder="地点名称" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <SelectComponent dictType="map_type" v-model="dataForm.type" placeholder="类型">
                </SelectComponent>
            </el-form-item>
             <el-form-item>
                <el-select v-model="dataForm.scenicId" placeholder="所属区域" clearable style="width:100%">
                    <el-option v-for="item in scenicOptions" :key="item.id" :label="item.scenicName" :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <!--<el-form-item>-->
                <!--<el-select v-model="dataForm.province" placeholder="省" clearable @change="val => regionChange(val, 'province')">-->
                    <!--<el-option v-for="item in provinceOptions" :key="item.id" :label="item.name" :value="item.id">-->
                    <!--</el-option>-->
                <!--</el-select>-->
            <!--</el-form-item>-->
            <!--<el-form-item>-->
                <!--<el-select v-model="dataForm.city" placeholder="市" clearable @change="val => regionChange(val, 'city')">-->
                    <!--<el-option v-for="item in cityOptions" :key="item.id" :label="item.name" :value="item.id">-->
                    <!--</el-option>-->
                <!--</el-select>-->
            <!--</el-form-item>-->
            <!--<el-form-item>-->
                <!--<el-select v-model="dataForm.area" placeholder="区" clearable @change="val => regionChange(val, 'area')">-->
                    <!--<el-option v-for="item in areaOptions" :key="item.id" :label="item.name" :value="item.id">-->
                    <!--</el-option>-->
                <!--</el-select>-->
            <!--</el-form-item>-->
            <!--<el-form-item>-->
                <!--<el-input v-model="dataForm.street" placeholder="街道" clearable></el-input>-->
            <!--</el-form-item>-->
            <!-- <el-form-item>
                <el-input v-model="dataForm.address" placeholder="详细地址" clearable></el-input>
            </el-form-item> -->
            <el-form-item>
                <el-button @click="getDataList()">{{ $t("query") }}</el-button>
            </el-form-item>
            <el-form-item v-if="$hasPermission('sys:ismap:export')">
                <el-button type="primary" @click="exportHandle()">{{
            $t("export")
          }}</el-button>
            </el-form-item>
            <el-form-item>
                <el-button v-if="$hasPermission('sys:ismap:save')" type="primary" @click="addOrUpdateHandle()">{{ $t("add") }}</el-button>
            </el-form-item>
            <el-form-item>
                <el-button v-if="$hasPermission('sys:ismap:delete')" type="danger" @click="deleteHandle()">{{ $t("deleteBatch") }}</el-button>
            </el-form-item>
            <el-form-item v-if="$hasPermission('sys:ismap:import')" >
                <el-button type="primary" @click="importHandle()" class="exportRoom">导入</el-button>
            </el-form-item>
        </el-form>
        <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle" style="width: 100%">
            <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
            <el-table-column prop="name" label="名称" sortable="custom" header-align="center" align="center" width="120" :show-overflow-tooltip="true"></el-table-column>
             <el-table-column prop="scenicName" label="所属区域" header-align="center" min-width="120" align="center"></el-table-column>
            <el-table-column prop="longitude" label="经度" header-align="center" align="center"></el-table-column>
            <el-table-column prop="latitude" label="纬度" header-align="center" align="center"></el-table-column>
            <el-table-column prop="typeName" label="类型" header-align="center" align="center"></el-table-column>
            <el-table-column prop="size" label="大小" sortable="custom" header-align="center" align="center"></el-table-column>
            <el-table-column prop="address" label="详细地址" header-align="center" align="center" min-width="150" :show-overflow-tooltip="true"></el-table-column>
            <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
                <template slot-scope="scope">
                    <el-button type="text" v-if="$hasPermission('sys:ismap:update')" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t("update") }}</el-button>
                    <!-- <el-button type="text" size="small" @click="viewHandle(scope.row)"
              >查看</el-button
            > -->
                    <el-button type="text" v-if="$hasPermission('sys:ismap:delete')" size="small" @click="deleteHandle(scope.row.id)">{{ $t("delete") }}</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
        </el-pagination>
        <!-- 导入 -->
        <import v-if="importVisible" ref="import" @refreshDataList="getDataList()"></import>
        <!-- 弹窗, 新增 / 修改 -->
        <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" :disabled="disabled" @changeDisabled="disabled = false"></add-or-update>
    </div>
</el-card>

</template>

<script>
 // import Import from './excelimport'
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./ismap-add-or-update";
import Import from './excel-import'
import mixinRegionModule from "@/mixins/region-module";
export default {
    mixins: [mixinViewModule,mixinRegionModule],
    data() {
        return {
            importVisible: false,
            disabled: false,
            mixinViewModuleOptions: {
                getDataListURL: "/sys/ismap/page",
                getDataListIsPage: true,
                exportURL: "/sys/ismap/export",
                deleteURL: "/sys/ismap",
                deleteIsBatch: true,
            },
            scenicOptions:[],
            dataForm: {
                province:'',
                city:'',
                area:'',
                scenicId:'',
                type:'',
            },
        };
    },
    watch: {},
    components: {
        AddOrUpdate,
        Import
    },
    mounted(){
        this.getScenicOptions();
        this.provincAreaDetailInfoList();
        if (this.dataForm.city) {
            this.cityAreaDetailInfoList(this.dataForm.province);
        }
        if (this.dataForm.area) {
            this.countyAreaDetailInfoList(this.dataForm.city);
        }
    },
    methods: {
         //岛屿
        getScenicOptions() {
            this.$http
                .get("scenic/isscenic/selectScenicList", {})
                .then(({
                    data: res
                }) => {
                    if (res.msg == "success") {
                        this.scenicOptions = res.data;
                    }
                });
        },
        //导入
        importHandle: function () {
            this.importVisible = true
            this.$nextTick(() => {
                this.$refs.import.init()
            })
        },
        viewHandle(row) {
            this.addOrUpdateVisible = true;
            this.disabled = true;
            this.$nextTick(() => {
                this.$refs.addOrUpdate.visible = true;
                this.$refs.addOrUpdate.dataForm = row;
            });
        },
    },
};
</script>
